<?php
require './config.php';

if(!empty($_POST['v_content']) && !empty($_POST['pid'])){
    $v_content = $_POST['v_content'];
    $pid = $_POST['pid'];
    $pid1 = $_POST['pid1'];
    $num = $_POST['mid'];
    $num=$num+1;
    $ming =  $_POST['mname'];
    if ($num=='1'){
        $lou='沙发';
    }
    elseif ($num=='2'){
        $lou='板凳';
    }
    elseif($num=='3'){
        $lou='地板';
    }else {
        $lou = $num .'楼';
    }
    $ctime = time();
    $sql = "insert into reply values(null,$pid1,{$pid},'{$v_content}',{$ctime},'1')";
    mysqli_query($link,$sql);
    if(mysqli_affected_rows($link)>0){
        $sql1 = "select * from userdetail where uid={$pid1}";
        $result1 = mysqli_query($link,$sql1);
        $rows1 = mysqli_fetch_assoc($result1);
        $rlogo = $rows1['photo'];
        $fh='x_';
        $hz=basename($rlogo);
        $rlogo = $fh.$hz;
        $arr = array(
            'error' => 2,
            'ctime' => date('Y-m-d H:i:s',$ctime),
            'content' => $v_content,
            'num'=>$lou,
            'logo'=>$rlogo,
            'ming'=>$ming,
        );
        mysqli_close($link);
        echo json_encode($arr);
    }else{
        $arr['error'] = 1;
        mysqli_close($link);
        echo json_encode($arr);
    }

}else{
    $arr['error'] = 1;
    echo json_encode($arr);
}

